﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using CosenSecurity;
using Newtonsoft.Json;
using Easy.Model;

namespace Easy.BLL
{
    public class BasePage : System.Web.UI.Page
    {
        private Guid _CurrentUserId;
        public Guid CurrentUserId { get { return _CurrentUserId; } }

        public BasePage()
        {
            this._CurrentUserId = new SystemUserManager().GetSystemUserByUserName(User.Identity.Name).SystemUserId;
        }

        public SystemUserModel GetSystemUser()
        {
            return new SystemUserManager().GetSystemUser(this._CurrentUserId);
        }

    }
    public class BaseHttpHandler : IHttpHandler, IRequiresSessionState
    {
        private Guid _CurrentUserId;
        public Guid CurrentUserId { get { return _CurrentUserId; } }
        public BaseHttpHandler()
        {
            this._CurrentUserId = new SystemUserManager().GetSystemUserByUserName(HttpContext.Current.User.Identity.Name).SystemUserId;
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }

        public virtual void ProcessRequest(HttpContext context)
        {
            throw new NotImplementedException();
        }


        public SystemUserModel GetSystemUser()
        {
            return new SystemUserManager().GetSystemUser(this._CurrentUserId);
        }
    }
}